/* USER CODE BEGIN Header */
/**
  ******************************************************************************
  * @file    usart.h
  * @brief   This file contains all the function prototypes for
  *          the usart.c file
  ******************************************************************************
  * @attention
  *
  * Copyright (c) 2024 STMicroelectronics.
  * All rights reserved.
  *
  * This software is licensed under terms that can be found in the LICENSE file
  * in the root directory of this software component.
  * If no LICENSE file comes with this software, it is provided AS-IS.
  *
  ******************************************************************************
  */
/* USER CODE END Header */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __USART_H__
#define __USART_H__

#ifdef __cplusplus
extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "main.h"

/* USER CODE BEGIN Includes */
#include "FreeRTOS.h"
#include "cmsis_os.h"
#include "stdio.h"
#include "string.h"
#include "stdarg.h"
#include "cfifo.h"
/* USER CODE END Includes */

extern UART_HandleTypeDef huart1;

extern UART_HandleTypeDef huart2;

/* USER CODE BEGIN Private defines */
extern osThreadId_t receiveTaskHandle;
extern uint8_t Cmd_Rx_Buffer[64];

#define usartPRINTF_HANDLE huart1
#define usartRF_HANDLE huart2

#ifdef __GNUC__
  /* With GCC/RAISONANCE, small printf (option LD Linker-Libraries-Small printf
     set to Yes) calls __io_putchar() */
  #define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
#else
  #define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)
#endif /* __GNUC__ */
/* USER CODE END Private defines */

void MX_USART1_UART_Init(void);
void MX_USART2_UART_Init(void);

/* USER CODE BEGIN Prototypes */

/**
 * @brief  Set the UART baud rate.
 * @param  huart: Pointer to a UART_HandleTypeDef structure that contains
 *               the configuration information for the specified UART module.
 * @param  bound_rate: The desired baud rate.
 * @return HAL_StatusTypeDef: HAL_OK on success, HAL_ERROR on failure.
 */
HAL_StatusTypeDef UART_Set_BoundRate(UART_HandleTypeDef *huart, uint32_t bound_rate);
int print_log(const char *format, ...);
void UART_Cmd_Init(void);
void UART_Send_Cmd(uint8_t *cmd, uint16_t len);
int8_t CRC8_Check(uint8_t *data, uint16_t length);
/* USER CODE END Prototypes */

#ifdef __cplusplus
}
#endif

#endif /* __USART_H__ */

